package com.hbnu.system.controller;


import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.Patentproject;
import com.hbnu.system.service.IPatentprojectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-05-16
 */
@RestController
@RequestMapping("/patentproject")
@Api(tags = "专利关联项目模块")
public class PatentprojectController {

    @Autowired
    IPatentprojectService iPatentprojectService;

    @ApiOperation("专利关联项目添加")
    @PostMapping("/AddPatentProject")
    public Rest<Boolean> AddPatentProject(@RequestBody Patentproject patentproject){
        boolean add = iPatentprojectService.addPatentProject(patentproject);
        return add ? Rest.success() : Rest.failed();
    }

    @ApiOperation("专利关联项目删除")
    @GetMapping("/RemovePatentProject")
    public Rest<Boolean> RemovePatentProject(String patentProjectID){
        boolean remove = iPatentprojectService.removePatentProject(patentProjectID);
        return remove ? Rest.success() : Rest.failed();
    }

    @ApiOperation("专利关联项目更新")
    @PostMapping("/UpdatePatentProject")
    public Rest<Boolean> UpdatePaperProject(@RequestBody Patentproject patentproject){
        boolean update = iPatentprojectService.updatePatentProject(patentproject);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("专利关联项目查询")
    @GetMapping("/GetPatentProjectByPatentID")
    public Rest<List<Patentproject>> GetPatentProjectByPatentID(String patentID){
        List<Patentproject> patentProjectByPatentID = iPatentprojectService.getPatentProjectByPatentID(patentID);
        return Rest.success(patentProjectByPatentID);
    }

}

